require('./index.css');
var _account_service = require('service/account-service.js');

var header ={
    init : function(){
        this.bindEvents();
        this.loadAccountInfo();
        return this;
    },
    bindEvents : function(){
        $('#signout-btn').click(
            function(){
                _account_service.logout(
                    function(res){
                        window.location.reload();
                    },
                    function(errMsg){
                        //DoNothing
                    }
                );
            }
        );
    },
    loadAccountInfo : function(){
        _account_service.checkLogin(
            function(res){
                $('#signInSpan').hide();
                $('#signOutSpan').show();
            },
            function(errMsg){
                // console.log('Error.....');
                $('#signOutSpan').hide();
                $('#signInSpan').show();
            }
        )
    }

};

module.exports = header.init();